#include "mainwindow.h"
#include <DApplication>
#include <QTranslator>
#include <QDebug>
#include <DAboutDialog>
#include <QFile>
#include <DApplicationSettings>
#include <QLocale>
#include <QDateTime>
int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    DApplication a(argc, argv);
    QTranslator translator;
    translator.load(a.applicationDirPath()+"/translations/appimage-installer_" + QLocale::system().name());
    qDebug()<<QLocale::system().name();
    a.loadTranslator();
    a.setAttribute(Qt::AA_UseHighDpiPixmaps);
    a.installTranslator(&translator);
    a.setProductIcon(QIcon::fromTheme("appimage-installer"));
    a.setProductName("AppImage Installer");
    QFile version(a.applicationDirPath()+"/data/version");
    qDebug()<<a.applicationDirPath()+"/data/version";
    version.open(QFile::ReadOnly);
    QString v(version.readAll());
    if(v.isEmpty()){
        QString dateTime;
        dateTime += __DATE__;
        dateTime += __TIME__;
        QDateTime build= QLocale(QLocale::English).toDateTime(dateTime, "MMM dd yyyyhh:mm:ss");
        int* year=new int;
        int* month=new int;
        int* day=new int;
        build.date().getDate(year,month,day);

        v=QString("dev:%1%2%3").arg(*year,4,10,QLatin1Char('0')).arg(*month,2,10,QLatin1Char('0')).arg(*day,2,10,QLatin1Char('0'));
    }
    a.setProductName("AppImage Installer");
    a.setOrganizationDomain("https://www.deepinos.org/");
    a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
    a.setApplicationName("AppImage Installer");
    a.setOrganizationName("Maicss");
    DAboutDialog* aboutdlg=new DAboutDialog;
    a.setAboutDialog(aboutdlg);
    aboutdlg->setVersion(v);
    aboutdlg->setDescription("一个可以很方便的安装的AppImage格式的软件。<br>作者：Maicss");
    aboutdlg->setProductName("AppImage Installer");
    aboutdlg->setProductIcon(QIcon::fromTheme("appimage-installer"));
    aboutdlg->setWebsiteName("gitee");
    aboutdlg->setWebsiteLink("https://gitee.com/deepin-opensource/appimage-installer");
    a.aboutDialog()->setCompanyLogo(QPixmap());
    DApplicationSettings as;
    Widget w;
    w.show();

    if(QString::fromUtf8(argv[1])!=""){
        w.open(QString::fromUtf8(argv[1]));
    }

    return a.exec();
}

